package com.jlf.tool.validation;


import com.jlf.tool.validation.constraint.IdCardConstraintValidator;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 身份证号码的校验
 *
 * @author wujr
 * 2021/1/13
 * @version 1.0
 * 变更历史
 * [wujr 2021/1/13 1.0 新增]
 */
@Documented
@Constraint(validatedBy = {IdCardConstraintValidator.class})
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Repeatable(IdCard.List.class)
public @interface IdCard {
    String message() default "{javax.validation.constraints.IdCard.message}";

    /**
     * 是否支持15位的身份证号码
     * @return 默认true
     */
    boolean i15() default true;

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };

    /**
     * Defines several {@code @IdCard} constraints on the same element.
     *
     * @see IdCard
     */
    @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
    @Retention(RUNTIME)
    @Documented
    @interface List {
        IdCard[] value();
    }
}
